﻿<!--#include file="const.inc"-->
<%
'====================================================================
' 感谢使用晴天3G智能建站系统..
' 作者:梁永强.QQ:766750857
' 官方网址:wap.qt3g.com
' 声明:软件版权归作者所有,没有经过作者本人同意不得非法破解和传播本程序
'====================================================================
%>

<%	dim rs,sql,i,id,PageCount,Page,PageOut,PageIn,PageSize,content,name,readcon,huicon,viphy,nid,time,dat

	PageSize=500

	id=Request.QueryString("id")
	if id="" then id=0
	if not isnumeric(id) then id=0
	id=clng(id)
	urls=Request.QueryString("urls")
        if urls="" then urls="viewv.asp?id="&id
    	Page = Request("page")      '当前页数
    	If Page = "" Then Page = 1
   	If Not IsNumeric(Page) Then Page = 1
    	Page = CLng(Page)
    	If Page < 1 Then Page = 1


	if sid<>"Null" then

	conn.execute("update qingtian_riji set readcon=readcon+1 where id="&id&"")

	Set Rs = Server.CreateObject("Adodb.Recordset")

	Sql = "select nid,name,conurl,readcon,huicon,time from qingtian_riji where id="&id
	Rs.Open Sql,conn,1,1
	if not (rs.bof and rs.eof)  then
                name=rs("name")
                nid=rs("nid")
                readcon=rs("readcon")
                huicon=rs("huicon")
                time=rs("time")
                urls1=rs("conurl")
		Dim path,FsoObj,tempfileOBJ,txt
		Path = server.mappath(Request.ServerVariables("SCRIPT_NAME"))
		Path=left(Path,instrrev(Path,"\" ) - 6 )
		path=Path & "/" & rs("conurl")

    		Set FsoObj=Server.CreateObject("Scripting.FileSystemObject")
		IF FSOObj.FileExists(path) = True then
   		Set tempfileOBJ = FsoObj.OpenTextFile(path, 1, 0, 0 )
    		While NOT tempfileOBJ.AtEndOfStream
			txt=txt & tempfileOBJ.ReadLine & vbNewLine 
    		Wend
		Set tempfileOBJ=Nothing
		end if
		Set FsoObj=Nothing
		if len(txt)>2 then txt=trim(left(txt,len(txt)-2))
		contentt=txt
		if Request.QueryString("act")<>1 then
		

		''''''''''''''''''智能分页''''''''''''''''''''''
      		Dim  n
        	I = 1
        	Do
            	n = n + 1
            	If n = page Then
           	     PageIn = I
           	End If
            	If InStr(I, contentt, "[page]") - I < PageSize + PageSize / 4 * 3 And InStr(I, contentt, "[page]") <> 0 Then
            	    I = InStr(I, contentt, "[page]") + 6
            	Else
            	    I = I + PageSize
            	End If
            	If n = page Then
            	    PageOut = I
            	End If

        	Loop While I < Len(contentt)
       		PageCount = n
		if page>PageCount then page=PageCount

		if Pagein="" then Pagein=(PageCount-1)*PageSize+1
		if Pageout="" then Pageout=Len(contentt)-(PageCount-1)*PageSize+Pagein

		if len(contentt)>0 then contentt=replace(mid(contentt,Pagein,Pageout-Pagein),"[page]","")
		else
			PageCount=1
			Page=1
		end if
        else
        if v=0 then
%>
<card title="出错了"><p align="<%=qingtian.px%>">
<%      else
%>
<title>出错了</title>
</head>
<body>
<!--#include virtual="/css.inc"-->
<%      end if
        qingtian.err("访问的日记不存在")
        end if
	Rs.close
select case v
case "0"
we0="<br/>"
hr="-----------------<br/>"
Randomize()
book1="跳到第<input name='Page' format='*N' size='2' maxlength='5'/><a href='viewv.asp?id="&id&"&amp;page=$(Page:n)&amp;sid="&sidd&"'>页</a><br/>"
book="<input name=""remark"" type=""text"" maxlength=""128"" emptyok=""true"" size='15' value="""" /><br/><anchor title=""发表评论"">发表评论<go href='showing.asp?id="&id&"&amp;sid="&sidd&"' method='post'><postfield name=""remark"" value=""$(remark)"" /></go></anchor><br/>"
%>
<card title="<%=qingtian.utf8(name)%>"><p align="<%=qingtian.px%>">
<%
case "1"
hr=""
zi="<span style=""color:#FF5500"">"
zi0="</span>"
we="<div class=""footer"">"
sou="<div class=""block4"">"
dao="<div class=""navi"">"
we0="</div>"
Randomize()
book1=""&dao&"<form action=""viewv.asp?id="&id&"&amp;sid="&sidd&""" method=""post"">跳到第<input type=""text"" name=""Page"" value="""" format=""*N"" size=""2"" maxlength=""5""/><input type=""submit"" value=""页"" /></form>"&we0&""
book=""&dao&"<form action=""showing.asp?id="&id&"&amp;sid="&sidd&""" method=""post""><input type=""text"" name=""remark"" size='15' value="""" /><br/><input type=""submit"" value=""发表评论"" /></form>"&we0&""
%>
<title><%=qingtian.utf8(name)%></title>
</head>
<body>
<!--#include virtual="/css.inc"-->
<%
End Select		


		%><%

		qingtian.info
qingtian.qingsav("424")
Response.Write(""&dao&"<a href=""/user/spacev.asp?nid="&nid&"&amp;sid="&sidd&""">"&qingtian.utf8(qingtian.name(nid))&"的空间</a>&gt;<a href=""index.asp?nid="&nid&"&amp;sid="&sidd&""">Ta的日记</a>&gt;日记阅读"&we0&"")
%>
		<%=sou%><b><%=qingtian.utf8(name)%>(阅<%=qingtian.utf8(readcon)%>)</b><%=we0%>
                <%=we%>[作者]:<a href="/user/spacev.Asp?nid=<%=nid%>&amp;sid=<%=sidd%>"><%=qingtian.utf8(qingtian.name(nid))%>(ID:<%=nid%>)</a><%=we0%>
	       <%=sou%>[时间]:<%=qingtian.FormatTime(time,0)%><%=we0%><%=hr%>
		<%=we%><%=qingtian.ubb(contentt)%><%=we0%><%=hr%>
		<%

	    	'分页
    		
		if  Request.QueryString("act")<>1 and  PageCount >1  Then 
    		    Response.Write("" & sou & "<a href='" & urls1 & "'>下载</a>|<a href='viewv.asp?act=1&amp;id="&id&"&amp;page=" & Page& "&amp;sid="&sidd&"'>全文</a>|")
		else
   		    Response.Write("" & sou & "<a href='" & urls1 & "'>下载</a>|<a href='viewv.asp?id="&id&"&amp;page=" & Page  & "&amp;sid="&sidd&"'>分页</a>" & we0 & "")
    		End If
    	
    		'分页
    		If Page < PageCount Then
    		    Response.Write("<a href='viewv.asp?id="&id&"&amp;page=" & Page + 1 & "&amp;sid="&sidd&"'>下页</a>")
    		End If
       
    		If Page > 1 And Page < PageCount Then
    		    Response.Write("|")
    		End If
        
    		If Page > 1 Then
    		    Response.Write("<a href='viewv.asp?id="&id&"&amp;page=" & Page - 1 & "&amp;sid="&sidd&"'>上页</a>" & we0 & "")
    		Elseif PageCount >1 then
    		    Response.Write("" & we0 & "")
    		End If
            
    		Randomize()
    
    		If PageCount > 2 Then
    		   %>
		<%=book1%>
		<% 
    		Response.Write("" & we & "(第" & Page & "/总" & PageCount & "页/"&len(txt)&"字)" & we0 & "")
   		End If
                                                                
 


		
		 %>
			<%=sou%>评论该日记:<%=we0%>	
		<%=book%>
		<%




		Sql = "select top 5 id,content,user,uid from qingtian_rijili where  listid="&id&"  order by id desc"

		Rs.Open Sql,conn,1,1
		if not (rs.bof and rs.eof)  then
		For i=1 to rs.RecordCount
dat=rs.RecordCount+1-i
dat1=dat mod 2
if dat1=0 then
%>
<%=we%><%=zi%><%=dat%>楼.<%=zi0%>[<%=qingtian.utf8(rs("user"))%>]说:<%=qingtian.ubb(rs("content"))%><%=we0%>
<%
else
%>
<%=sou%><%=zi%><%=dat%>楼.<%=zi0%>[<%=qingtian.utf8(rs("user"))%>]说:<%=qingtian.ubb(rs("content"))%><%=we0%>
<%
                End If
		Rs.MoveNext
		next
	
		%>
			<%=we%><a href="showinglist.asp?infoid=<%=id%>&amp;sid=<%=sidd%>">查看网友评论(<%=huicon%>条)</a><%=we0%>
		<%
	else
%>
<%=we%>暂无评论！<%=we0%>
<%
 	end if
	Rs.close
	
	set rs=nothing
%><%=hr%>
<%=qingtian.qingsav("425")%><%=sou%><a href="<%=qingtian.backurl(urls)%>">返回来源页</a><%=we0%> 
<%
else
Response.Redirect "/login.asp?sid=" & sidd & "&url=/riji/viewv.asp?id="&id&""
end if
end Function
%>
